package com.wm.blog_gateway.config;

import com.wm.blog_gateway.service.TRouteService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/***
 * @ClassName: GatewayAppStartupRunner
 * @Description: 网关服务启动时自动刷新数据库/redis中的路由,防止重启路由丢失
 * @Author: 半卷流年
 * @Create_time: 13:43 2020-3-28
 */

/**
 * commandLineRunner、ApplicationRunner 接口是在容器启动成功后的最后一步回调（类似开机自启动）。
 */

@Slf4j
@AllArgsConstructor
@Component
public class GatewayAppStartupRunner implements CommandLineRunner {

    private final TRouteService routeService;

    @Override
    public void run(String... args) throws Exception {
      log.info("网关服务启动初始化路由数据");
      //TODO 接入redis实现
      //初始化路由信息
        routeService.refresh();
    }
}
